package org.example.mapper;


import org.example.model.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper {
    @Insert("INSERT INTO course (name, teacher, description, create_time, update_time) VALUES (#{name}, #{teacher}, #{description}, now(), now())")
    int insertCourse(Course course);

    @Update("UPDATE course SET name = #{name}, teacher = #{teacher}, description = #{description}, update_time = now() WHERE id = #{id}")
    int updateCourse(Course course);

    @Delete("DELETE FROM course WHERE id = #{id}")
    int deleteCourse(Long id);

    @Select("SELECT * FROM course WHERE id = #{id}")
    Course getCourseById(Long id);

    @Select("SELECT * FROM course")
    List<Course> getAllCourses();
}